<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class WaterStorageOut extends Model
{
    use \App\Models\Traits\ScopeCompanySite;
    use \App\Models\Traits\Site;
    
    protected $fillable = [ "company_id", "site_id", "creater_uid", "creater_name", "status" ];
    // protected $guarded = [];
    
    protected $casts = [
        'company_id'=>'integer',
        'site_id'=>'integer',
        'creater_uid'=>'integer',
    ];
    
    public function getCompanyField() {
        return 'company_id';
    }
    
    public function getSiteField() {
        return 'site_id';
    }
    
    //项目信息
    public function companies() {
        return $this->hasOne('App\Models\Company', "Co_ID", "company_id");
    }
    //站点
    public function sites() {
        return $this->hasOne('App\Models\Site', "id", "site_id");
    }
    
    //出库商品
    public function shops() {
        return $this->belongsToMany('App\Models\WaterMyStorage', 'water_storage_out_shops')->withPivot('out_num')->withTimestamps();
    }
}
